/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager.editar;

import br.com.deployment.entidade.registroimovel.Operacao;
import br.com.deployment.message.Msg;
import br.com.deployment.servico.OperacaoServico;
import java.io.IOException;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author luciano
 */
@ManagedBean
@SessionScoped
public class ManagerEditarOperacao implements Serializable{
    
    @EJB
    OperacaoServico operacaoServico;
    
    private Operacao operacao;
    
    public void atualizar(){
        operacaoServico.atualizar(operacao);
        Msg.messagemInfo("Operação salva com sucesso.");
    }
    
     public void redirect(String string, Operacao operacao) {
        try {
            FacesContext context = FacesContext.getCurrentInstance();
            this.operacao = operacao;
            context.getExternalContext().redirect(string);
        } catch (IOException ex) {
            Logger.getLogger(ManagerEditarOperacao.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public Operacao getOperacao() {
        return operacao;
    }

    public void setOperacao(Operacao operacao) {
        this.operacao = operacao;
    }
    
    public void editarOperacao(Operacao operacao) throws IOException{
        FacesContext.getCurrentInstance().getExternalContext().redirect("/Cartorio-war/editarTipoSelo.xhtml");
        this.operacao = operacao;
    }
}
